﻿// Decompiled with JetBrains decompiler
// Type: Microsoft.InfoCards.SecondaryIndexDefinition
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// MVID: 8E14765A-6610-409A-BA36-099A0642905D
// Assembly location: E:\git\ALLIDA\windll\infocard.exe

using Microsoft.InfoCards.Diagnostics;
using System;

namespace Microsoft.InfoCards
{
  internal sealed class SecondaryIndexDefinition
  {
    private static readonly SecondaryIndexDefinition[] s_masterIndexes = new SecondaryIndexDefinition[8]
    {
      new SecondaryIndexDefinition("ix_globalid", 10, 20, SecondaryIndexSettings.Unique, Canonicalizers.Binary),
      new SecondaryIndexDefinition("ix_objecttype", 10, 20, SecondaryIndexSettings.None, Canonicalizers.Binary),
      new SecondaryIndexDefinition("ix_name", 10, 20, SecondaryIndexSettings.Nullable, Canonicalizers.CaseInsensitiveWithHashing),
      new SecondaryIndexDefinition("ix_production_svc_uri", 10, 20, SecondaryIndexSettings.Nullable, Canonicalizers.CaseInsensitiveWithHashing),
      new SecondaryIndexDefinition("ix_parentid", 10, 20, SecondaryIndexSettings.Nullable, Canonicalizers.Binary),
      new SecondaryIndexDefinition("ix_masterkey", 10, 20, SecondaryIndexSettings.Nullable | SecondaryIndexSettings.Unique, Canonicalizers.BinaryWithHashing),
      new SecondaryIndexDefinition("ix_supportclaim", 50, 20, SecondaryIndexSettings.Nullable, Canonicalizers.CaseSensitiveWithHashing),
      new SecondaryIndexDefinition("ix_supportauth", 10, 20, SecondaryIndexSettings.Nullable, Canonicalizers.Binary)
    };
    public const string GlobalIdIndex = "ix_globalid";
    public const string ObjectTypeIndex = "ix_objecttype";
    public const string NameIndex = "ix_name";
    public const string RecipientIdIndex = "ix_name";
    public const string ProductionServiceIndex = "ix_production_svc_uri";
    public const string ParentIdIndex = "ix_parentid";
    public const string MasterKeyIndex = "ix_masterkey";
    public const string SupportedClaimIndex = "ix_supportclaim";
    public const string SupportedAuthIndex = "ix_supportauth";
    private int m_initialSize;
    private int m_growthFactor;
    private SecondaryIndexSettings m_settings;
    private string m_name;
    private ICanonicalizer m_canonicalizer;

    private SecondaryIndexDefinition(
      string name,
      int initialSize,
      int growthFactor,
      SecondaryIndexSettings settings,
      ICanonicalizer canonicalizer)
    {
      if (string.IsNullOrEmpty(name))
        throw InfoCardTrace.ThrowHelperArgumentNull(nameof (name));
      if (initialSize <= 0)
        throw InfoCardTrace.ThrowHelperError((Exception) new ArgumentOutOfRangeException(nameof (initialSize), (object) initialSize, SR.GetString("StoreIndexInitialSizeInvalid")));
      if (canonicalizer == null)
        throw InfoCardTrace.ThrowHelperArgumentNull(nameof (canonicalizer));
      if (growthFactor <= 0)
        throw InfoCardTrace.ThrowHelperError((Exception) new ArgumentOutOfRangeException(nameof (growthFactor), (object) growthFactor, SR.GetString("StoreIndexGrowthFactorInvalid")));
      this.m_initialSize = initialSize;
      this.m_growthFactor = growthFactor;
      this.m_settings = settings;
      this.m_name = name;
      this.m_canonicalizer = canonicalizer;
    }

    public static SecondaryIndexDefinition[] MasterIndexes
    {
      get
      {
        return SecondaryIndexDefinition.s_masterIndexes;
      }
    }

    public ICanonicalizer Canonicalizer
    {
      get
      {
        return this.m_canonicalizer;
      }
    }

    public string Name
    {
      get
      {
        return this.m_name;
      }
    }

    public int InitialSize
    {
      get
      {
        return this.m_initialSize;
      }
    }

    public int GrowthFactor
    {
      get
      {
        return this.m_growthFactor;
      }
    }

    public SecondaryIndexSettings Settings
    {
      get
      {
        return this.m_settings;
      }
    }

    public static SecondaryIndexDefinition GetByName(string name)
    {
      for (int index = 0; index < SecondaryIndexDefinition.s_masterIndexes.Length; ++index)
      {
        if (SecondaryIndexDefinition.s_masterIndexes[index].Name == name)
          return SecondaryIndexDefinition.s_masterIndexes[index];
      }
      return (SecondaryIndexDefinition) null;
    }
  }
}
